<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/12/11
  Time: 11:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%--<%=session.getServletContext().getContextPath()+"hello"%>--%>
  <head>
    <title>demo</title>
      <%--<script>
          function loadXMLDoc()
          {
              alert("dada")
              var xmlhttp;
              if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
              }
              else
              {// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
              xmlhttp.onreadystatechange=function()
              {
                  if (xmlhttp.readyState==4 && xmlhttp.status==200)
                  {
                      //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
                      alert(xmlhttp.responseText);
                  }
              }
              xmlhttp.open("POST","/login",true);
              xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
              xmlhttp.send("name=Bill&pwd=Gates");
          }
      </script>--%>
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#login").click(function () {
                var name = $("#name").val();
                //alert(name);
                var pwd = $("#pwd").val();
                //alert(pwd);
                $.post("/login",{name:name,password:pwd},function (data, status) {
                    alert(data);
                    if (data != "null"){
                        window.location.href="main.jsp";
                        //$(da/ta).each("name")
                    }else{
                        alert("登录失败");
                    }
                })

            });
        });
    </script>
  </head>
  <body>
<div style="text-align: center">
  用户名：<input type="text" name="name" id="name" required><br>
  密码：<input type="text" name="pwd" id="pwd" required><br>
  <input type="button" value="登录" id="login" onclick="loadXMLDoc()">
</div>
  </body>
</html>
